package com.frxuexi.apps

import com.frxuexi.lib_base.BaseViewModel
import com.frxuexi.lib_base.entity.ApiResponse
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

@HiltViewModel
class AppsViewModel @Inject constructor(private val appsRepository: AppsRepository):BaseViewModel<AppsIntent> (){
    override fun handleIntent(it: AppsIntent) {
        when(it){
            is AppsIntent.getApps->{
                httpRequest(appsRepository.getApps(it.map) as Flow<ApiResponse<Any>>)
            }
            is AppsIntent.download->{
                downloadApk(it.url,it.path)
            }
        }
    }
}